package com.smileymedia.smil.stage;

import com.smileymedia.smil.content.SmilContent;

/**
 * Timeline element 
 * Time tracking implementing according to 
 * http://service.real.com/help/library/guides/production8/htmfiles/smil.htm#69771
 * @author gbugaj
 *
 */
public class Timeline {
	public Timeline() {

	}

	/**
	 * Stops the animation
	 */
	public void stop() {

	}
	/**
	 * Start the animation
	 */
	public void start() {

	}
	/**
	 * Pause the animation
	 */
	public void pause() {

	}

	public void setStartTime(double startTime) {
		mStartTime = startTime;
	}


	public double getStartTime() {
		return mStartTime;
	}

	public void setEndTime(double endTime) {
		mEndTime=endTime;
	}

	/**
	 * Absolute end time of when the timeline ends onthe stage
	 * @return
	 */
	public double getEndTime() {
		double total=getStartTime()+getTotalPlayTime();
		return total;
	}

	
	
	/**
	 * This returns calculated duration either set via start/end or via duration
	 * @return
	 */
	public double getDuration() {		
		return mDuration;
	}

	public void setDuration(double duration) {		
		mDuration=duration;
		hasDuration=true;
	}

	/**
	 * Get the total time the timeline will be visible on the screen
	 * @return
	 */
	public double getTotalPlayTime(){
		double total=0d;
		if(hasDuration){
			total=mDuration;
		}else{
			total=mEndTime-mStartTime;
		}		
		return total;
	}


	public SmilContent getContent() {
		return mContent;
	}

	public void setContent(SmilContent mContent) {
		this.mContent = mContent;
	}

	
	@Override
	public String toString() {
		return "Timeline ="+mContent;
	}

	private double mStartTime;
	private double mEndTime;
	private double mDuration;
	private boolean hasDuration;

	//Content associated with this timeline
	private SmilContent mContent;

	
}
